package cn.android.mydata2.listener;

import android.content.Context;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

/**
 * Created by Administrator on 2016/10/30.
 */

public class PhoneListen extends PhoneStateListener {
    private Context context;
    public PhoneListen(Context c) {
        context=c;
    }
    @Override
    public void onDataConnectionStateChanged(int state) {
        switch(state) {
            case TelephonyManager.DATA_DISCONNECTED:// 3G
                //3G has been turned OFF
                Log.e("Listener","3g off");
                break;
            case TelephonyManager.DATA_CONNECTING:// 3G
                //3G is connecting
                Log.e("Listener","3g connecting");
                break;
            case TelephonyManager.DATA_CONNECTED:// 3G
                //3G has turned ON
                Log.e("Listener","3g on");
                break;
        }
    }
}
